package momo.multitree.algo;

import momo.multitree.structure.*;

import java.util.LinkedHashMap;
import java.util.LinkedHashSet;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;


public class CostShortestPath extends ModifiedDijkstra {

	private Log log = LogFactory.getLog(CostShortestPath.class);
		
	@Override
	public double calObjCost(LinkedHashSet<Node> S, Node node,
			LinkedHashSet<Edge> Et, Edge edgeToAdd, LinkedHashMap<Node, Double> labels ) {
		
		Node inTree = null;
		if (edgeToAdd.getHeadNode().equals(node))
			inTree = edgeToAdd.getTailNode();
		else
			inTree = edgeToAdd.getHeadNode();
		
		double currCost = labels.get(inTree);
		
		//log.debug("aaaaa");
		//log.debug("l("+inTree.getId()+")="+currCost);
		double adjCost = currCost + edgeToAdd.getCost(inTree);
		
		return adjCost;
	}

}
